{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "p67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Don't panicl\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panicl\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panicl\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', 'l']\n",
      "['o', 'n', \"'\", 'p', 't', ' ', 'a']\n",
      "on'pt a\n"
     ]
    }
   ],
   "source": [
    "phrase = \"Don't panicl\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "plist.pop(0)\n",
    "plist.extend([plist.pop(),plist.pop()])\n",
    "plist.insert(2,plist.pop())\n",
    "plist.insert(2,plist.pop(3))\n",
    "new_phrase = ''.join(plist)\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "p81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panicl\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', 'l']\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', 'l']\n",
      "ont pa\n"
     ]
    }
   ],
   "source": [
    "phrase = \"Don't panicl\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "new_phrase=''.join(plist[1:3])\n",
    "new_phrase=new_phrase+''.join([plist[4],plist[5],plist[6],plist[7]])\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "p89列表总结"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.列表是Python最常用的数据类型之一，其形式是:列表名=[元素1，元素 2，元素3....1\n",
    "列表是用中括号包起来的。列表的元素可以是数字 字符串，甚至是另一个列表。列表的是一个\n",
    "有序、可更改的集合。\n",
    "2.语法格式： 用英文中括号包裹元素，不同元素用英文逗号隔开 \n",
    "\n",
    "元素查找：用索引和反向索引获取指定位置的元素，用index()方法获取元素的正向索引\n",
    "\n",
    "元素修改： 用列表[索引]=新值的方式修改指定位置的元素 \n",
    "元素添加：\n",
    "用append()方法在列表末尾添加元素\n",
    "用insert()方法中间某一位置插入元素   \n",
    "                                \n",
    "pop() 返回并删除指定位置的元素 \n",
    "del 语句 通过索引删除元素 \n",
    "remove() 通过具体的值删除元素 \n",
    "count() 统计元素出现的次数 \n",
    "sort() 可以对列表内的元素进行排序 \n",
    "列表常用方法 reverse() 将列表顺序反转 \n",
    "copy() 复制一个同样的列表 \n",
    "clear() 清空列表 \n",
    "in 判断列表中是否包含某一元素 \n",
    "+ 将两个列表链接在一起 \n",
    "*将列表元素重复多次生成新列表\n",
    "                                \n",
    "                                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
